/**
 * author:Administrator
 * date:2013-5-21
 */
package com.roc.web.action;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * @author Administrator
 *
 */
public class PowerSearchCondition extends BaseSearchCondition {
	
	
	private String accountNo;
	private String mobile;
	private String realName;
	private String cardNo;
	private String merType;
	private String orgCode;
	private String merLevel;
	private Object[] merchantNos;
	

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		
		return " order by t.dtCreate  DESC  ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
		
		return " select count(*) from Merchant t where 1=1  ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		
		return " from Merchant t where 1=1 ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		
		if (Constance.isNotEmpty(accountNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.accountNo", accountNo.trim()
					.trim(), "=", false));
		}

		if (Constance.isNotEmpty(realName)) {
			filedBeanList.add(new WhereHQLFieldBean("t.realName", realName.trim(),
					"LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(mobile)) {
			filedBeanList.add(new WhereHQLFieldBean("t.mobile", mobile.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(cardNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.cardNo", cardNo.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(merType)&&!"99".equals(merType)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merType", merType.trim()
					.trim(), "=", false));
		}
        
		if (Constance.isNotEmpty(orgCode)) {
			if(!orgCode.equals("99")){
				filedBeanList.add(new WhereHQLFieldBean("t.orgCode", orgCode.trim()
						.trim(), "=", false));
			}
		}
		
		if (Constance.isNotEmpty(merLevel)) {
			if(!merLevel.equals("99")){
				filedBeanList.add(new WhereHQLFieldBean("t.merLevel", merLevel.trim()
						.trim(), "=", false));
			}
		}
		if(merchantNos!=null&&merchantNos.length>0){
        	filedBeanList.add(new WhereHQLFieldBean("t.accountNo",merchantNos,
					"IN", false));
        }

		return filedBeanList;
	}

	/**
	 * @return the accountNo
	 */
	public String getAccountNo() {
		return accountNo;
	}

	/**
	 * @param accountNo the accountNo to set
	 */
	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	/**
	 * @return the mobile
	 */
	public String getMobile() {
		return mobile;
	}

	/**
	 * @param mobile the mobile to set
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	/**
	 * @return the realName
	 */
	public String getRealName() {
		return realName;
	}

	/**
	 * @param realName the realName to set
	 */
	public void setRealName(String realName) {
		this.realName = realName;
	}

	/**
	 * @return the cardNo
	 */
	public String getCardNo() {
		return cardNo;
	}

	/**
	 * @param cardNo the cardNo to set
	 */
	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	

	/**
	 * @return the merType
	 */
	public String getMerType() {
		return merType;
	}

	/**
	 * @param merType the merType to set
	 */
	public void setMerType(String merType) {
		this.merType = merType;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getMerLevel() {
		return merLevel;
	}

	public void setMerLevel(String merLevel) {
		this.merLevel = merLevel;
	}

	public Object[] getMerchantNos() {
		return merchantNos;
	}

	public void setMerchantNos(Object[] merchantNos) {
		this.merchantNos = merchantNos;
	}

	
}
